home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Applications / Macintosh Tracker 1.20 / source / Tracker Client Folder / Core 18⁄March⁄1994 / Main.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-25  |  2.4 KB  |  107 lines  |  [TEXT/KAHL]

  1. /* Main.c */
  2.  
  3. /* this contains the main code (which isn't much) which initializes the system and */
  4. /* invokes the event loop */
  5.  
  6. #include "MiscInfo.h"
  7. #include "CMyApplication.h"
  8. #include "CMyScrap.h"
  9. #include "MenuController.h"
  10. #include "EventLoop.h"
  11. #include "Memory.h"
  12. #include "Compatibility.h"
  13. #include "CWindow.h"
  14. #include "Profiler.h"
  15.  
  16.  
  17. void    InitSystem(void);
  18.  
  19.  
  20. #if __option(mc68020)
  21.     #define CodeFor68020
  22. #else
  23.     #define CodeFor68000
  24. #endif
  25. #pragma options(!mc68020) /* this code works no matter what */
  26.  
  27.  
  28. /* initialize the operating system */
  29. void    InitSystem(void)
  30.     {
  31.         InitGraf(&thePort);
  32.         InitFonts();
  33.         FlushEvents(everyEvent,0);
  34.         InitWindows();
  35.         InitMenus();
  36.         TEInit();
  37.         InitDialogs(&MyResumeProc);
  38.         InitCursor();
  39.     }
  40.  
  41.  
  42. /* the main loop */
  43. void    main(void)
  44.     {
  45.         #if __option(profile)
  46.         InitProfile(ProfileNumSymbols,ProfileNumLevels);
  47.         #endif
  48.  
  49.         /* initialize the operating system's things */
  50.         InitSystem(); /* now initialize the rest of the system */
  51.         InitPRERR(); /* this gets first pick of the memory */
  52.         INITAUDIT();
  53.         InitCompatibility(); /* find out what kind of system we are running on */
  54.         InitMemory();
  55.  
  56.         #if __option(mc68881)
  57.             if (!HasMathCoprocessor)
  58.                 {
  59.                     PRERR(ForceAbort,"This program requires a math coprocessor.");
  60.                 }
  61.         #endif
  62.  
  63.         #ifdef CodeFor68020
  64.             if (!Has020orBetter)
  65.                 {
  66.                     PRERR(ForceAbort,"This program requires a 68020 or better.");
  67.                 }
  68.         #endif
  69.  
  70.         if (!HasAppleEvents || !HasFSSpecStandardFile || !HasFSSpec || !HasFindFolder
  71.             || !HasGreyishTextOr)
  72.             {
  73.                 PRERR(ForceAbort,"This program needs System 7.0 or better to run.");
  74.             }
  75.  
  76.         /* initialize the major components of the program */
  77.         Application = new CMyApplication;
  78.         Scrap = new CMyScrap;
  79.         Scrap->IScrap();
  80.         InitMyMenus();
  81.         Application->InitMenuBar();
  82.  
  83.         InitMyEventLoop();
  84.         if (!FirstMemCacheValid())
  85.             {
  86.                 PRERR(ForceAbort,"There is not enough memory for this program to run.  "
  87.                     "Try increasing it's partition size or quitting some other programs.");
  88.             }
  89.         ActiveWindow = Application;
  90.         ActiveWindow->DoResume();
  91.         TheEventLoop(NIL);  /* this IS the main event loop */
  92.         ShutDownMyEventLoop();
  93.  
  94.         /* this is the shutdown sequence */
  95.         Scrap->CommitSuicide();
  96.         ShutDownMyMenus();
  97.         /* give the application one more chance to do something */
  98.         delete Application; /* always the last to go */
  99.  
  100.         FlushMemory();
  101.         ENDAUDIT();
  102.     }
  103.  
  104. #ifdef CodeFor68020
  105.     #pragma options(mc68020) /* turn it back on if necessary */
  106. #endif
  107.